package com.xx.ems.model;

import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import com.xx.ems.util.impl.ObjectTransformImpl;

/**
 * @author xxx
 * @date 2014-2-25
 * @version 1.0
 * 描述: 附件表
 */
@Entity
public class Accessory {
	/**
	 * 描述：主键
	 */
	private Integer aid;
	/**
	 * 描述：附件编号
	 */
	private String anumber;
	/**
	 * 描述：附件名称
	 */
	private String aname;
	/**
	 * 描述：附件价格
	 */
	private Double aprice;
	/**
	 * 描述：附件型号
	 */
	private String amodel;
	/**
	 * 描述：设备状态表关联对象 (附件状态)
	 */
	private Estatus status;
	/**
	 * 描述：设备表关联对象
	 */
	private Equipments equipments;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="aid",unique=true,nullable=false)
	public Integer getAid() {
		return aid;
	}
	public void setAid(Integer aid) {
		this.aid = aid;
	}
	@Column(name="anumber",length=20,nullable=false)
	public String getAnumber() {
		return anumber;
	}
	public void setAnumber(String anumber) {
		this.anumber = anumber;
	}
	@Column(name="aname",length=255,nullable=false)
	public String getAname() {
		return aname;
	}
	public void setAname(String aname) {
		this.aname = aname;
	}
	@Column(name="aprice",nullable=false)
	public Double getAprice() {
		return aprice;
	}
	public void setAprice(Double aprice) {
		this.aprice = aprice;
	}
	@Column(name="amodel",length=50)
	public String getAmodel() {
		return amodel;
	}
	public void setAmodel(String amodel) {
		this.amodel = amodel;
	}
	@ManyToOne(targetEntity=Estatus.class)
	@JoinColumn(name="fk_status")
	public Estatus getStatus() {
		return status;
	}
	public void setStatus(Estatus status) {
		this.status = status;
	}
	@ManyToOne(targetEntity=Equipments.class)
	@JoinColumn(name="fk_eid")
	public Equipments getEquipments() {
		return equipments;
	}
	public void setEquipments(Equipments equipments) {
		this.equipments = equipments;
	}
	/**
	 * 描述: 将实体的属性及相应的值转换成Map类型(为了方便转换成json格式后前台调用) 
	 * @return
	 * @date 2014-3-3
	 */
	public Map<String, Object> toHashMap() {
		Map<String, Object> map = new ObjectTransformImpl().javabeanToMap(this);
		map.put("status", getStatus().getSname());
		map.remove("equipments");
		return map;
	}
}